export type Props = {
    lng: number
    lat: number
}
class CenterPoint {
    AMap: any
    mapContainer: any
    maker: any
    lng: number
    lat: number

    constructor(props: Props, AMap, map) {
        this.AMap = AMap
        this.mapContainer = map

        this.lat = props.lat
        this.lng = props.lng
    }

    setMaker = (lng: number, lat: number) => {
        this.setPosition(lng, lat)
        if (this.maker) {
            this.maker.remove()
        }
        this.maker = new this.AMap.Marker({
            position: [lng, lat],
        });
        this.mapContainer.add(this.maker);
    }

    setMakerAndShift = (lng: number, lat: number) => {
        this.setMaker(lng, lat)
        this.mapContainer.setCenter([lng, lat]);
    }

    setPosition = (lng: number, lat: number) => {
        this.lng = lng;
        this.lat = lat;
    }
}

export default CenterPoint